package com.versa.artflowlib;

import android.app.IntentService;
import android.content.Intent;

import com.versa.lib.Versa;
import com.versa.lib.VersaBuilder;
import com.versa.lib.listeners.CompletionListener;
import com.versa.lib.listeners.ImageSavedListener;
import com.versa.lib.listeners.ProgressListener;

/**
 * Created by huyaonan on 17/2/15.
 */
public class StyleService extends IntentService {
    public static final String ACTION_START = "com.naman14.arcade.START";
    /**
     * Creates an IntentService.  Invoked by your subclass's constructor.
     *
     * @param name Used to name the worker thread, important only for debugging.
     */
    public StyleService(String name) {
        super(name);
    }
    public StyleService() {
        super("StyleService");
    }

    @Override
    protected void onHandleIntent(Intent intent) {
        stylize();
    }
    private void stylize() {
        VersaBuilder builder = new VersaBuilder(this);
        final Versa arcade = builder.build();
        arcade.initialize();
        arcade.setLogEnabled(true);
        arcade.setProgressListener(new ProgressListener() {
            @Override
            public void onUpdateProgress(final String log, boolean important) {
                System.out.println("::::::onUpdateProgress");
            }
        });
        arcade.setImageSavedListener(new ImageSavedListener() {
            @Override
            public void onImageSaved(String path) {
                System.out.println("::::::onImageSaved:" + path);
            }
        });
        arcade.setCompletionListsner(new CompletionListener() {
            @Override
            public void onComplete() {
                System.out.println("::::::onComplete");
            }
        });
        arcade.stylize(1);
    }
}
